//
//  WmcValidationCodeView.swift
//  YPWatermarkCamera
//
//  Created by 马涛 on 2022/6/22.
//

import UIKit

class WmcValidationCodeView: WmcBaseView {
    lazy var textfield: UITextField = {
        let view = UITextField()
        view.placeholder = "请输入验证码"
        view.font = 14.yp.uiFont
        view.keyboardType = .numberPad
        return view
    }()

    lazy var validationButton: WmcCountdownButton = {
        let view = WmcCountdownButton()
        view.titleLabel?.font = 14.yp.uiFont
        view.setTitle("获取验证码", for: .normal)
        view.setTitleColor(UIColor.wmc_mainTheme, for: .normal)
        return view
    }()

    lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.wmc_lineColor
        return view
    }()

    override func makeUI() {
        addSubview(textfield)
        addSubview(validationButton)
        addSubview(lineView)

        validationButton.snp.makeConstraints { make in
            make.right.equalToSuperview()
            make.top.bottom.equalToSuperview()
            make.centerY.equalToSuperview()
            make.width.equalTo(80)
            make.height.equalTo(45.wmc_autoVer)
        }
        textfield.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
            make.right.equalTo(validationButton.snp.left).offset(-12)
        }
        lineView.snp.makeConstraints { make in
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(1)
        }
    }

    override func bindViewAction() {
    }
    
    func releaseTimer() -> Void {
        validationButton.timer?.invalidate()
        validationButton.timer = nil
    }
}
